//
//  SINAStudentServiceOherItemTableViewCell.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/3.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINAStudentServiceOherItemTableViewCell.h"
#import "SINACircularBeadUtils.h"
#import "SINAUiviewClickLiserner.h"
#import "SINACalendarUtils.h"
#import "SINALabelUtils.h"

@interface SINAStudentServiceOherItemTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *userSexImageView;
//头像
@property (weak, nonatomic) IBOutlet UIImageView *titleImageView;
//服务时间
@property (weak, nonatomic) IBOutlet UILabel *serviceTimeLabel;
//服务地址
@property (weak, nonatomic) IBOutlet UILabel *serviceLocationLabel;
//姓名
@property (weak, nonatomic) IBOutlet UILabel *userNamelabel;
//酬金
@property (weak, nonatomic) IBOutlet UILabel *moneyLabel;
@end

@implementation SINAStudentServiceOherItemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setBackgroundColor:[UIColor colorWithHexString:@"#fafafa"]];
    [SINACircularBeadUtils makeCircularView:self.titleImageView];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void)setModel:(SINAStudentServiceItemModel *)model{
    _model=model;
    //姓名
    self.userNamelabel.text=model.userName;
    [SINALabelUtils updateLabel:self.userNamelabel andWithString:model.nickname];
    //服务时间
    self.serviceTimeLabel.text = [NSString stringWithFormat:@"服务时间：%@-%@",[SINACalendarUtils getDateStringWithTimeStr:model.serviceStartTime andFormat:@"HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:model.serviceEndTime andFormat:@"HH:mm"]];
    
    
    //服务地点
    if (model.serviceLocation!=nil&&model.serviceLocation.length>0&&![model.serviceLocation isEqualToString:@"(null)"]) {
        self.serviceLocationLabel.text=[NSString stringWithFormat:@"服务地点：%@",model.serviceLocation];
    }else{
        self.serviceLocationLabel.text=[NSString stringWithFormat:@"服务地点：无"];
    }
    //酬金
    self.moneyLabel.text=[NSString stringWithFormat:@"酬金:%@RMB",model.moneyNumber];
    
    //性别
    self.userSexImageView.hidden=NO;
    if (model.userSex==1) {
        self.userSexImageView.image = [UIImage imageNamed:@"男"];
    } else if (model.userSex==2){
        self.userSexImageView.image = [UIImage imageNamed:@"女"];
    }else{
        self.userSexImageView.hidden=YES;
    }
    
    //头像
    model.userTitleImageUrl=[model.userTitleImageUrl stringByReplacingOccurrencesOfString:@"\\" withString:@"//"];
    [self.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.userTitleImageUrl]  placeholderImage:[UIImage imageNamed:@"默认头像"]];
    
    WeakSelf;
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.contentView andWithBlick:^(UIView *view) {
        if (weakSelf.itemClickBlock) {
            weakSelf.itemClickBlock(weakSelf.model);
        }
    }];
}

@end
